#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>

/*
int main()
{   
    printf("%d\n",getpid());
    FILE*fp=fopen("log.txt","w");
    const char*str="hello,linux\n";
    int cnt=5;
    while(cnt)
    {
       cnt--;
       fwrite(str,strlen(str),1,fp);
    }
    
    sleep(1000);
    fclose(fp);
    return 0;
}
*/

/*
int main()
{
    umask(0);
    printf("%d\n",getpid());
    int fd=open("log.txt",O_WRONLY|O_CREAT,0666);
    const char*str="xxxx";
    int cnt=1;
    int size=0;
    while(cnt)
    {
       cnt--;
       size=write(fd,str,strlen(str));
    }
    printf("%d\n",size); 
    sleep(1);
    close(fd);
    return 0;
}
*/

/*
int main()
{
   close(0);
   //close(2);
   int fd = open("log.txt", O_RDONLY);
   if(fd < 0)
   {
     perror("open");
     return 1;
   }
   printf("fd: %d\n", fd);
   close(fd);
   return 0;
}

*/


#define ONE 1<<0
#define TWO 1<<1
#define THREE 1<<2
#define FOUR 1<<3


void Show(int flag)
{
    if(flag&ONE)printf("one\n");
    if(flag&TWO)printf("two\n");
    if(flag&THREE)printf("three\n");
    if(flag&FOUR)printf("four\n");
}


int main()
{
    Show(ONE);
    printf("----------------\n");
    Show(ONE|TWO);
    printf("----------------\n");
    Show(ONE|TWO|THREE);
    return 0;
}









